export default {
    addAllToShopCart(context, list) {
        context.commit("addAllToShopCart", null === list ? [] : list);
    },
    addToShopCart(context, info) {
        return new Promise(resolve => {
            if (info) {
                let findItem = context.state.shopCartList.find(item => item.iid === info.iid && item.xdSkuId === info.xdSkuId);
                if (findItem) {
                    context.commit("changeGoodsCount", {item: findItem, purchaseCount: info.purchaseCount});
                } else {
                    context.commit("addNewProducts", info);
                }
            }
            resolve();
        });
    },
    changeGoodsCount(context, {item, purchaseCount}) {
        context.commit("changeGoodsCount", {item, purchaseCount});
    },
    changeGoodsCheck(context, item) {
        context.commit("changeGoodsCheck", item);
    },
    changeAllCheck(context, isSelectAll) {
        if (!isSelectAll) {
            context.commit("selectAllCheck");
        } else {
            context.commit("noSelectAllCheck")
        }
    }
}